import React, { Component } from 'react'
import { HashRouter as Router, Route, Link } from 'react-router-dom'
import CacheRoute,{CacheSwitch} from 'react-router-cache-route'



class Index extends Component{
  constructor(props) {
    super(props)
    console.log('组件Index');
  }
  render() {
    return <div>
      <h1>index</h1>
    </div>
  }
}
class User extends Component{
  constructor(props) {
    super(props)
    console.log('组件User');
  }
  render() {
    return <div>
      <h1>User</h1>
    </div>
  }
}
export default class App extends Component {
  render() {
    return (
      <div>
        <Router>
          <Link to='/index'>7777</Link>
          <Link to='/user'>8888</Link>
          <CacheSwitch>
          <CacheRoute path='/index' component={Index}></CacheRoute>
          <Route path='/user' component={User}></Route>
          </CacheSwitch>
        </Router>
      </div>
    )
  }
}
